﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace AspCategoriesEdit
{
    public partial class Add : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Cancel_Click(object sender, EventArgs e)
        {
            Response.Redirect("Default.aspx");
        }

        protected void saveBtn_Click(object sender, EventArgs e)
        {
            if (nameTxt.Text != "" && nameTxt.Text.Length <= 15)
            {
                DataLayer.Add(nameTxt.Text, descriptionTxt.Text);
                Response.Redirect("Default.aspx");
            }
            else
            {
                error.Text = "Invalid Category Name";
            }
        }
    }
}